<template>
  <div class="header">
    <div class="l-content">
      <el-button size="small" @click = "handleCollapse">
        <component class="icons" is="menu"></component>
      </el-button>
      <el-breadcrumb separator="/" class="bread">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
      </el-breadcrumb>

    </div>
    <div class="r-content">
      <el-dropdown>
            <span class="el-dropdown-link">
                <img :src="getImageUrl('user')" class="user"/>
            </span>
        <template #dropdown>
          <el-dropdown-menu>
            <el-dropdown-item>个人中心</el-dropdown-item>
            <el-dropdown-item>退出</el-dropdown-item>
          </el-dropdown-menu>
        </template>
      </el-dropdown>
    </div>
  </div>
</template>


<script setup lang='ts'>

import {useAllDataStore} from "../stores";

const store = useAllDataStore()
const getImageUrl = (user: string) => {
  return new URL(`../assets/images/${user}.png`, import.meta.url).href
}

const handleCollapse = () => {
  store.state.isCollapse  = !store.state.isCollapse
}
</script>


<style lang="less" scoped>
.header {
  /* 启用 Flex 布局 */
  display: flex;
  // 主轴对齐方式
  justify-content: space-between;
  // 交叉轴对齐方式
  align-items: center;
  width: 100%;
  height: 100%;
  background-color: #333;
}

.icons {
  width: 20px;
  height: 20px;
}

.l-content {
  display: flex;
  align-items: center;

  .el-button {
    margin-right: 20px;
  }
}

.r-content {
  .user {
    width: 40px;
    height: 40px;
    // 圆角
    border-radius: 50%;
  }
}

// 面包屑 deep 伪类选择器，用于穿透作用域限制，对子组件中的.bread span 元素进行样式设置
:deep(.bread span) {
  // 字体颜色
  color: #fff !important;
  // 鼠标样式 !important  是为了确保优先级 覆盖默认样式
  cursor: pointer !important;
}

</style>
